﻿using System;
using System.Globalization;
using System.Windows.Data;
using WWLauncher.ViewModel;

namespace WWLauncher.Converts
{
    public class MenuInfoConvert : IValueConverter
    {
        private readonly MainViewModel mainViewModel = MainViewModel.Instance();
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int menuIndex = mainViewModel.SelectedMenuIndex;
            if (menuIndex == -1)
            {
                return "";
            }
            else
            {
                string type = parameter?.ToString();
                if ("1".Equals(type))
                {
                    return mainViewModel.MenuList[menuIndex].MenuGeometry;
                }
                else
                {
                    return mainViewModel.MenuList[menuIndex].MenuName;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
